home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / sun4.md / varargs.h < prev    next >
C/C++ Source or Header  |  1991-06-11  |  1KB  |  50 lines

  1. /*
  2.  * varargs.h --
  3.  *
  4.  *    Macros for handling variable-length argument lists.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /sprite/src/lib/include/sun4.md/RCS/varargs.h,v 1.4 91/02/01 16:24:28 rab Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _VARARGS
  19. #define _VARARGS
  20.  
  21. #ifndef _VA_LIST
  22. #define _VA_LIST
  23. typedef char *va_list;
  24. #endif
  25.  
  26. /*
  27.  * An argument of list of __builtin_va_alist causes the sun4 compiler
  28.  * to store all the input registers, %i0 to %i5, in the stack frame
  29.  * so the var_arg() macro will be able to reference them in memory.
  30.  */
  31. #define va_alist __builtin_va_alist
  32.  
  33. #define va_dcl int __builtin_va_alist;
  34.  
  35. #define va_start(AP) (__builtin_saveregs(), (AP) = (char *)&__builtin_va_alist)
  36.  
  37. #define __va_rounded_size(TYPE)  \
  38.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  39.  
  40. #define va_arg(AP, TYPE)                        \
  41.  ((AP) += __va_rounded_size (TYPE),                    \
  42.   *((TYPE *) ((AP) - __va_rounded_size (TYPE))))
  43.  
  44.  
  45. /*  #define va_arg(list, type)  ((type *)(list += sizeof(type)))[-1]  */
  46.  
  47. #define va_end(list)
  48.  
  49. #endif /* _VARARGS */
  50.